; (function () {
  Array.prototype.delArrCf = function () {
    var res = [this[0]];
    for (var i = 1; i < this.length; i++) {
      var repeat = false;
      for (var j = 0; j < res.length; j++) {
        if (this[i].projectId == res[j].projectId) {
          repeat = true;
        }
      }
      if (!repeat) {
        res.push(this[i]);
      }
    }
    return res;
  };

  new Vue({
    el: '#ct-creat1',
    data: {
			mCode: hlUrlUtil.GetQueryString('m_code'),
			relet: hlUrlUtil.GetQueryString('relet'),
      contractId: hlUrlUtil.GetQueryString('id'),
      zlfType: {
        list: [{ name: '公司租赁', type: 'C' }, { name: '个人租赁', type: 'P' }],
        active: 'C'
      },
      contactType: {
        list: [{ name: '整租合同', type: 'ER' }, { name: '工位合同', type: 'WR' }],
        active: 'ER'
      },
      channelType: {
        list: [],
        selected: { 'name': null, 'code': null }
      },
      channelName: {
        list: [],
        selected: { 'name': null, 'code': null }
      },
      allChannelNameList: [],
      industryTypes: {
        list: [{ memo: '' }],
        active: null,
        name: null
      },
      customers: [],
      customersFlag: false,
      zlfData: {
        zlf_name: '',
        zlf_id: null,
        zlf_lperson: null,
        zlf_sperson: null,   //租赁方签订人
        zlf_lphone: null,   //租赁方法人手机
        zlf_sphone: null,   //租赁方签订人手机
        zlf_address: null,
        m_code: null,    //管理编号
        c_code: null,    //合同编号
        memo: null,       //备注
        name: null,    //合同名
        idcode: null,    //识别号
        email: null,     //邮箱
        shortName: null
      },
      projects: {
        list: [],
        selectedProjectName: '',  // 选定的项目名
        builddata: [],
        floorsdata: [],
        unitdata: [],
        stWpdata: [],
        id: null,
        buildingId: null,
        floorId: null,
        unitId: null
      },
      unitData: [],
      wpData: [],
      stData: [],
      wpNum: 0,        // 工位数
      stNum: 0,        // 车位数
      // 弹出层控制
      bounced: {
        unitFlag: false,
        stFlag: false,
        wpFlag: false
      },
      projectInfo: {
        project_id: null,
        project_name: null,
        contract_no_prefix: null,
        contract_name_prefix: null,
        units: [],
        stdata: [],
        wpdata: [],
        unitFlag: false,
        stFlag: false,
        wpFlag: false
      },
      getname: {
        buildname: null,
        unitname: null,
        floorname: null,
        fname: null,
        stop_acreage: null
      },
      uIndex: null,
      intent: {
        id: null,
        intentDeductibleAmount: null
      },
      fileList: [],
      progress: '',
      validate: null,
      /////////////////////自定字段////////////
      ZDYdata: [],
      selectedData: [],
			tmpData: [],
      resData: [],

      /////////////////////中介////////////
      mediationData:''

    },
    computed: {
      wpNum: function () {
        var num = 0;
        this.wpData.map(function (item) {
          item.stop.map(function (list) {
            num++
          })
        })
        return num
      },
      stNum: function () {
        var num = 0;
        this.stData.map(function (item) {
          item.stop.map(function (list) {
            num++
          })
        })
        return num
      }
    },
    watch: {
      contractId (val, old) {
        console.log(val, old)
      }

    },
    methods: {
      // 获取合同自定义字段
      getZDYData(val) {
        var that = this
        hlhttp.get({
          url: 'configure/customize_column',
          data: {
            "module": "HETN",// 所属模块code
            "config_name": "HT_CUSTOMIZE_COLUMNS"// 配置名称
          },
          success: function (res) {
            if (window.sessionStorage.getItem('CREATED_CONTRACT_FIRST_STEP')) {
              that.ZDYdata = JSON.parse(window.sessionStorage.getItem('CREATED_CONTRACT_FIRST_STEP')).ZDYdata;
              return
            }
            let arr = [...res.customizeColumns,...res.systemColumns]
            for (var i = arr.length - 1; i >= 0; i--) {
              if (arr[i].isValid == 'false') {
                arr.splice(i,1)
              }
            }//去除多余数据（未启动，无关联）
            // if(val){
            //   arr = hlArrayUtil.removeRepeat([...val,...arr], 'configCode');
            // }
            console.log(arr)
             //若有合同详情，则合并,去重（保留合同）
            let textList = []
            let noTextList = []
            arr.map((item,index) =>{
              if(item.fieldType == 'text'){
                textList.push(item)
              }else{
                noTextList.push(item)
              }
            })
            arr = [...noTextList,...textList]
            //重新排序，将文本类型放到最后
            arr.map(item => {
              if(!item.select){
                if (item.fieldType == 'radio' || item.fieldType == 'checkbox' || item.fieldType == 'select' ) {
                  item.select = [];
                  item.selectArr = item.fieldRange.split(',')
                  item.selectArrCopy = []
                  item.selectArr.map(item0 => {
                    item.selectArrCopy.push({
                      name: item0,
                      code: item0
                    })
                  })

                } else {
                  item.select = '';
                }
              }
            })

            if(val){
              val.map(item =>{
                arr.map(single =>{
                  if(single.configCode == item.configCode){
                    single.select = item.select
                  }
                })
              })
            }
          that.ZDYdata = arr
          }
        })
      },
      // 获取合同详情
      getContractDetail: function (id) {
        var self = this;
        let url = 'contract'
        let data = { id: self.contractId }
        if (hlUrlUtil.GetQueryString('relet') == 'true') {
          url = 'contract/renewal'
          data = { contract_id: self.contractId }
        }
        hlhttp.get({
          url: url,
          data: data,
          success: function (data) {

						console.log(data.pageCustomizeComponentBizContentList)

						self.tmpData = data.pageCustomizeComponentBizContentList ? data.pageCustomizeComponentBizContentList : []

            let cache = JSON.parse(window.sessionStorage.getItem('CREATED_CONTRACT_FIRST_STEP'))
            console.log(cache)
            if (cache) {
              cache.zlfData.m_code = data.mCode
              Object.assign(self.$data, cache)
              return
            }

            if (data.attachmentNames) {
              if (data.attachmentNames.length) {
                data.attachmentNames.map((item, index) => {
                  self.fileList.push({
                    name: item,
                    url: data.attachmentUrls[index]
                  })
                })
              }
            }
            if(data.customConfigProperty){
              self.getZDYData(JSON.parse(data.customConfigProperty))
            }else{
              self.getZDYData()
            }

            self.channelType.selected = { 'name': data.channelCategoryVal, 'code': data.channelCategoryCode }
            self.channelName.selected = { 'name': data.channelNameVal, 'code': data.channelNameCode }
            // 合同信息
            self.projectInfo.project_id = data.projectId;
            self.projectInfo.project_name = data.projectName;
            self.zlfData.m_code = data.mCode;
            self.zlfData.c_code = data.cCode;
            self.zlfData.memo = data.memo;
            self.zlfData.name = data.name;
            // 意向合同信息
            if (data.relatedIntentId) {
              self.intent.id = data.relatedIntentId
              self.intent.intentDeductibleAmount = data.intentDeductibleAmount
            }

            // 乙方信息
            self.zlfData.zlf_name = data.zlfCompany;
            self.zlfData.zlf_id = data.zlfId;
            self.zlfData.idcode = data.idcode;
            self.zlfData.email = data.email;
            self.zlfData.zlf_lperson = data.zlfLperson;
            self.zlfData.zlf_sperson = data.zlfSperson;
            self.zlfData.zlf_lphone = data.zlfLphone;
            self.zlfData.zlf_sphone = data.zlfSphone;
            self.zlfData.zlf_address = data.zlfAddress;
            self.zlfData.shortName = data.shortName;
            self.industryTypes.active = data.zlfIndustryType;
            self.industryTypes.list.map(function (item) {
              if (item.dictCode == self.industryTypes.active) {
                self.industryTypes.name = item.dictName;
              }
            })
            self.zlfType.active = data.zlfType;
            // 房源信息
            self.contactType.active = data.contractType;
            self.projects.id = data.projectId;
            self.projects.selectedProjectName = data.projectName || '';
            // 单元  整租合同才能够出租单元
            if (data.contractType === 'ER') {
              if (data.units.length !== 0) {
                var unitsArr = [];
                data.units.map(function (_item) {
                  if (_item.positions.length === 0) {
                    var obj = {
                      'building_id': _item.buildingId,
                      'building_name': _item.buildingName,
                      'floor_id': _item.floorId,
											'business_type': _item.businessType,
                      'floor_name': _item.floorName,
                      'unit_name': _item.unitName,
                      'unit_acreage': _item.unitAcreage,
                      'unit_id': _item.unitId,

                    }
                    unitsArr.push(obj)
                  }
                })
                self.projectInfo.units = unitsArr;
                self.unitData = JSON.parse(JSON.stringify(unitsArr));
                self.projectInfo.unitFlag = true;
              }
            }
            // 车位
            if (data.units.length !== 0) {
              var stArr = [];
              var stNum = 0;
              data.units.map(function (_item) {
                if (_item.positions.length > 0 && _item.unitType === 'ST') {
                  var obj = {
                    'building_id': _item.buildingId,
                    'building_name': _item.buildingName,
                    'floor_id': _item.floorId,
                    'floor_num': _item.floorNum,
                    'floor_name': _item.floorName,
                    'unit_id': _item.unitId,
                    'unit_name': _item.unitName,
                    'unit_acreage': _item.unitAcreage,
                    'stop': _item.positions
                  }
                  stArr.push(obj)
									stArr.map(item => {
									  item.stop.map(single => {
									    single.stop_name = single.positionName,
											single.business_type = single.businessType
									  })
									})
                  stNum += _item.positions.length;
                }
              })
              if (stArr.length !== 0) {
                self.projectInfo.stFlag = true;
                self.projectInfo.stdata = stArr;
                self.stData = JSON.parse(JSON.stringify(stArr));
                self.stNum = stNum;
              }
            }
            // 工位
            if (data.units.length !== 0) {
              var wpArr = [];
              var wpNum = 0;
              data.units.map(function (_item) {
                if (_item.positions.length > 0 && _item.unitType === 'WP') {
                  var obj = {
                    'building_id': _item.buildingId,
                    'building_name': _item.buildingName,
                    'floor_id': _item.floorId,
                    'floor_num': _item.floorNum,
                    'floor_name': _item.floorName,
                    'unit_id': _item.unitId,
                    'unit_name': _item.unitName,
                    'unit_acreage': _item.unitAcreage,
                    'stop': _item.positions
                  }
                  wpArr.push(obj)
                  wpArr.map(item => {
                    item.stop.map(single => {
                      single.stop_name = single.positionName,
											single.business_type = single.businessType
                    })
                  })
                  wpNum += _item.positions.length;
                }
                if (wpArr.length !== 0) {
                  self.projectInfo.wpFlag = true;
                  self.projectInfo.wpdata = wpArr;
                  self.wpData = JSON.parse(JSON.stringify(wpArr));
                  self.wpNum = wpNum;
                }
              })
            }

          }
        })
      },
      // 删除上传的文件
      delFileItem(index) {
        this.fileList.splice(index, 1)
        window.sessionStorage.setItem('contract_upload_file', JSON.stringify(this.fileList))
      },
      // 上传文件
      uploadFile: function () {
        if (this.progress) {
          hl.toast('文件尚未上传完成')
          return
        }
        $('.upload-file-button').trigger('click')
      },
      //选择公司个人
      selcp: function (type) {
        this.zlfType.active = type;
      },
      //获取行业列表
      getindustryTypes: function () {
        var _this = this;
        hlhttp.get({
          url: 'configure/industry/dict',
          success: function (data) {
            _this.industryTypes.list = data;
          }
        })
      },
      //设置行业类型
      setiType: function (type, name) {
        this.industryTypes.active = type;
        this.industryTypes.name = name;
      },
      // 获取渠道分类
      getChannelType() {
        var that = this
        hlhttp.get({
          url: 'configure/dict',
          data: { 'module_code': 'ZHSH', 'config_name': 'ZS_CHANNEL_CATE' },
          success: res => {
            that.channelType.list = res;
            if (that.contractId) {
              that.getContractDetail(that.contractId)
            }else{
              that.getZDYData()
            }
          }
        })
      },
      // 获取渠道名称
      getChannelName() {
        hlhttp.get({
          url: 'configure/dict',
          data: { 'module_code': 'ZHSH', 'config_name': 'ZS_CHANNEL_NAME' },
          success: res => {
            this.allChannelNameList = res;
          }
        })
      },
      // 选择渠道分类
      selectChannelType(code, name) {
        this.channelType.selected = { 'name': name, 'code': code }
        this.channelName.selected = { 'name': null, 'code': null }
        this.channelName.list = this.allChannelNameList.filter(el => el.parentDictCode == code)
        this.mediationData = ''
      },
      // 选择渠道名称
      selectChannelName(ops) {
        this.channelName.selected = { 'name': ops.name, 'code': ops.code }
        if(ops.code == '#'){
          this.mediationData = ''
          return
        }
        hlhttp.get({
          url: 'configure/getIntermediaryInfoByDictCode',
          data: {
            dict_code: ops.code
          },
          success: res => {
            this.mediationData = res
          }
        })
      },
      //获取公司名字
      inputCname: function () {
        var flag = true;

        var _this = this;
        len = this.zlfData.zlf_name;
        this.zlfData.zlf_id = null;
        this.industryTypes.active = null;
        this.industryTypes.name = null;
        this.zlfData.zlf_lperson = '';
        this.zlfData.zlf_lphone = '';
        this.zlfData.zlf_sperson = '';
        this.zlfData.zlf_sphone = '';
        this.$refs.channelTypeHtml.innerHTML = ''
        this.zlfData.zlf_address = ''
        this.zlfData.idcode = ''
        this.zlfData.email = ''
        this.channelType.selected.name = ''
        this.channelType.selected.code = ''
        this.channelName.selected.name = ''
        this.channelName.selected.code = ''

        $('#industry-st span').text('请选择行业')
        if (!this.zlfData.zlf_name) {
          _this.customersFlag = false;
          return
        }
        if (isNull(this.zlfData.zlf_name)) {
          _this.customersFlag = false;
          return
        }

				let power = JSON.parse(localStorage.getItem('permissions'))
				if (power.indexOf('c152') == -1 && power.indexOf('c43') == -1) {
					hl.toast('无客户管理权限')
					return
				}

        if (len.length != len.length + 1) {
          hlhttp.get({
            url: 'customers/_search',
            data: {
              begin_date: '#',  //付款开始日期
              end_date: '#',  //付款结束日期
              key_word: _this.zlfData.zlf_name.trim(),  //关键字
              customer_state: '#', //客户状态
              black_state: '#', //Y黑名单客户，N不是黑名单
              page: 1,  //请求页 Int
              page_size: 10000,  //每页数量 Int
              rperson_ids: '#',
              columns: '#',
              orders: '#',
							is_myself: power.indexOf('c43') > -1 ? 'N' : 'Y'
            },
            success: function (data) {
              var temp = data.customers;
              var str = '';
              if (!temp.length) {
                return
              }

              _this.customers = temp;
              _this.customersFlag = true;
              for (var i = 0; i < temp.length; i++) {
                if (temp[i].name === _this.zlfData.zlf_name) {
                  _this.industryTypes.active = temp[i].industryCode
                  _this.zlfData.zlf_id = temp[i].id
                  _this.zlfData.zlf_lperson = temp[i].legalPersonName
                  _this.zlfData.zlf_sperson = temp[i].lperson
                  _this.zlfData.zlf_sphone = temp[i].phone
                  _this.zlfData.idcode = temp[i].idcode
                  _this.zlfData.email = temp[i].email
                  _this.industryTypes.name = temp[i].industryVal
                  _this.channelType.selected = { name: temp[i].channelCategoryVal, code: temp[i].channelCategoryCode }
                  _this.channelName.selected = { name: temp[i].channelNameVal, code: temp[i].channelNameCode }
                  _this.$refs.channelTypeHtml.innerHTML = temp[i].channelCategoryVal
                  _this.zlfData.zlf_address = temp[i].address
                  _this.zlfData.shortName = temp[i].shortName
                  $('#industry-st span').text(temp[i].industryVal)
                }
              }
            }
          })
        }
      },
      //点击获取公司
      setClickCname: function (item) {
        this.zlfData.zlf_name = item.name;
        this.zlfData.zlf_id = item.id;
        this.zlfData.zlf_lperson = item.legalPersonName;
        this.zlfData.zlf_sperson = item.lperson;
        this.zlfData.zlf_sphone = item.phone;
        this.zlfData.idcode = item.idcode;
        this.zlfData.email = item.email;
        this.industryTypes.name = item.industryVal;
        this.industryTypes.active = item.industryCode;
        this.channelType.selected = { name: item.channelCategoryVal, code: item.channelCategoryCode }
        this.channelName.selected = { name: item.channelNameVal, code: item.channelNameCode },
        this.$refs.channelTypeHtml.innerHTML = item.channelCategoryVal
        $('#industry-st span').text(item.industryVal)
        this.zlfData.zlf_address = item.address
        this.zlfData.shortName = item.shortName
        this.customersFlag = false;
        event.stopPropagation()
        if(item.channelCategoryCode == 'INTERMEDIARY' && item.channelNameCode){
          this.selectChannelName({
            name:item.channelNameVal,
            code:item.channelNameCode,
          })
        }
      },
      //设置合同类型
      setContactType: function (type) {
        this.contactType.active = type;
        this.wpData = [];
        this.unitData = [];
        this.stData = [];
        this.projectInfo.wpdata = [];
        this.projectInfo.units = [];
        this.projectInfo.stdata = [];

        if (window.sessionStorage.getItem('CREATED_CONTRACT_SECOND_STEP')) {
          var d = JSON.parse(window.sessionStorage.getItem('CREATED_CONTRACT_SECOND_STEP'));
          d.rentBill = {
            oPrice: null,
            dRent: null,
            mRent: null,
            bet: null,
            pay: null,
            menoy: null,
            proportion: null,
            day: d.rentBill.day
          };
          d.rentLadder = [];
          d.freePeriod = [];
          window.sessionStorage.setItem('CREATED_CONTRACT_SECOND_STEP', JSON.stringify(d))
        }
      },
      //获取项目id
      getProjectsId: function (id, name, contractNoPrefix, contractNamePrefix) {
        this.projects.id = id;
        this.projectInfo.project_id = id;
        this.projectInfo.project_name = name;

        this.wpData = [];
        this.unitData = [];
        this.stData = [];
        this.projectInfo.wpdata = [];
        this.projectInfo.units = [];
        this.projectInfo.stdata = [];

        if (contractNoPrefix) { this.zlfData.c_code = contractNoPrefix + (this.zlfData.c_code || '') }
        if (contractNamePrefix) { this.zlfData.name = contractNamePrefix + (this.zlfData.name || '') }
      },
      //获取楼宇id:
      getBuildId: function (id, name) {
        this.projects.buildingId = id;
        this.getname.buildname = name;
        this.projects.stWpdata = [];
        $('.floor-select span, .unit-select span, .building-select span').text('请选择')
        var _this = this;
        hlhttp.get({
          url: 'building/floors',
          data: {
            project_id: _this.projects.id,
            building_id: id,
          },
          success: function (res) {
            _this.projects.unitdata = [];
            if (res.length === 0) {
              hl.toast('暂无楼层，请重新选择')
              return false
            }
            _this.projects.floorsdata = res
          }
        })
      },
      // 获取合同管理编号
      getContractCode: function () {
        var _this = this;
        hlhttp.get({
          url: 'contract/mcode',
          success: function (data) {
            _this.zlfData.m_code = data.mcode
            if (window.sessionStorage.getItem('CREATED_CONTRACT_FIRST_STEP')) {
              _this.zlfData.m_code = JSON.parse(window.sessionStorage.getItem('CREATED_CONTRACT_FIRST_STEP')).zlfData.m_code;
            }
          }
        })
      },
      //获取楼宇
      getBuildings: function (n) {
        if (!this.projects.id) return;
        var _this = this;
        if (n == 1) this.bounced.unitFlag = true;
        if (n == 2) this.bounced.wpFlag = true;
        if (n == 3) this.bounced.stFlag = true;
        $('.unit-select span').text('请选择')

        hlhttp.get({
          url: 'project/buildings',
          data: { project_id: _this.projects.id },
          success: function (res) {
            _this.projects.builddata = res
          }
        })
      },
      //获取单元
      getUnit: function (id, fname) {
        this.projects.floorId = id;
        this.getname.fname = fname;
        var _this = this;
        this.projects.unitdata = [];
        $('.last-unit span').removeClass('active')
        $('.unit-select span').text('请选择')
        hlhttp.get({
          url: 'floor/units',
          data: {
            project_id: _this.projects.id,
            floor_id: _this.projects.floorId,
            building_id: _this.projects.buildingId
          },
          success: function (res) {
            if (res.length === 0) {
              hl.toast('暂无单元，请重新选择')
              return false
            }
            _this.projects.unitdata = res
            setTimeout(function () {
              _this.selectUnit()
            }, 200);
          }
        })
      },
      //查询
      queryUnit: function () {
        if (!this.projects.floorId) return;
        var _this = this;
        hlhttp.get({
          url: 'floor/units',
          data: {
            project_id: _this.projects.id,
            floor_id: _this.projects.floorId,
            building_id: _this.projects.buildingId
          },
          success: function (res) {
            if (res.length === 0) {
              hl.toast('暂无单元，请重新选择')
              return false
            }
            _this.projects.unitdata = res
          }
        })
      },
      //选中取消单元
      selUnit: function (e, i, id) {
        var data = this.projects.unitdata;
        for (var l = 0; l < this.projectInfo.units.length; l++) {
          if (data[i].unitId == this.projectInfo.units[l].unit_id) {
            this.projectInfo.units.splice(l, 1)
          }
        }
        if (!$(e.srcElement).hasClass('active')) {
          $(e.srcElement).addClass('active')
          this.projectInfo.units.push({
            building_id: data[i].buildingId,
            building_name: this.getname.buildname,
            floor_id: data[i].floorId,
            floor_num: data[i].floor,
            floor_name: this.getname.fname,
            unit_id: data[i].unitId,
            business_type: data[i].businessType,
            unit_name: data[i].unitName,
            unit_acreage: data[i].acreage
          })
        } else {
          $(e.srcElement).removeClass('active')
        }
      },
      //选中取消车位
      selUnitSt: function (e, i, id, name, item) {
        var data = this.projects.unitdata;
				console.log(item)
        var acreage = null;
        if (!$(e.srcElement).hasClass('active')) {
          $(e.srcElement).addClass('active')
          if (!this.projectInfo.stdata.length) {
            this.projectInfo.stdata.push({
              building_id: this.projects.buildingId,
              building_name: this.getname.buildname,
              floor_id: this.projects.floorId,
              floor_num: this.getname.floorname,
              floor_name: this.getname.fname,
              unit_id: this.projects.unitId,
              unit_name: this.getname.unitname,
              stop: [{
                stop_id: id,  //车位ID
                stop_name: name,
								business_type: item.businessType,
              }],
              unit_acreage: data[this.uIndex].acreage
            })
          } else {
            var flag = false; index = null;
            for (var j = 0; j < this.projectInfo.stdata.length; j++) {
              if (this.projectInfo.stdata[j].unit_id == this.projects.unitId) {
                index = j;
                flag = 1;
              } else {
                index = j;
                flag = 2;
              }
            }
            if (flag == 1) {
              this.projectInfo.stdata[index].stop.push({ stop_id: id, stop_name: name, business_type: item.businessType, })
            }
            if (flag == 2) {
              this.projectInfo.stdata.push({
                building_id: this.projects.buildingId,
                building_name: this.getname.buildname,
                floor_id: this.projects.floorId,
                floor_num: this.getname.floorname,
                floor_name: this.getname.fname,
                unit_id: this.projects.unitId,
                unit_name: this.getname.unitname,
                stop: [{
                  stop_id: id,  //车位ID
                  stop_name: name,
									business_type: item.businessType,
                }],
                unit_acreage: data[this.uIndex].acreage
              })
            }
          }
        } else {
          $(e.srcElement).removeClass('active')
          for (var j = 0; j < this.projectInfo.stdata.length; j++) {
            let item = this.projectInfo.stdata[j];

            for (var k = 0; k < item.stop.length; k++) {
              if (item.stop[k].stop_id == id) {
                item.stop.splice(k, 1)
              }
            }
          }
        }
      },
      //选中取消工位
      selUnitWp: function (e, i, id, name, item) {
        var data = this.projects.unitdata;

        if (!$(e.srcElement).hasClass('active')) {
          $(e.srcElement).addClass('active')
          if (!this.projectInfo.wpdata.length) {
            this.projectInfo.wpdata.push({
              building_id: this.projects.buildingId,
              building_name: this.getname.buildname,
              floor_id: this.projects.floorId,
              floor_num: this.getname.floorname,
              floor_name: this.getname.fname,
              unit_id: this.projects.unitId,
              unit_name: this.getname.unitname,
              stop: [{
                stop_id: id,  //车位ID
                stop_name: name,
								business_type: item.businessType,
              }],
              unit_acreage: data[this.uIndex].acreage
            })
          } else {
            var flag = false; index = null;
            for (var j = 0; j < this.projectInfo.wpdata.length; j++) {
              if (this.projectInfo.wpdata[j].unit_id == this.projects.unitId) {
                index = j;
                flag = 1;
              } else {
                index = j;
                flag = 2;
              }
            }
            if (flag == 1) {
              this.projectInfo.wpdata[index].stop.push({ stop_id: id, stop_name: name, business_type: item.businessType, })
            }
            if (flag == 2) {
              this.projectInfo.wpdata.push({
                building_id: this.projects.buildingId,
                building_name: this.getname.buildname,
                floor_id: this.projects.floorId,
                floor_num: this.getname.floorname,
                floor_name: this.getname.fname,
                unit_id: this.projects.unitId,
                unit_name: this.getname.unitname,
                stop: [{ stop_id: id, stop_name: name, business_type: item.businessType, }],
                unit_acreage: data[this.uIndex].acreage
              })
            }
          }
        } else {
          $(e.srcElement).removeClass('active')
          for (var j = 0; j < this.projectInfo.wpdata.length; j++) {
            let item = this.projectInfo.wpdata[j];

            for (var k = 0; k < item.stop.length; k++) {
              if (item.stop[k].stop_id == id) {
                item.stop.splice(k, 1)
              }
            }
          }
        }
      },
      //勾选单元
      selectUnit: function () {
        var _this = this;
        for (var i = 0; i < this.projectInfo.units.length; i++) {
          $('.unit-active span').each(function (index, el) {
            if ($(el).attr('data-unitid') == _this.projectInfo.units[i].unit_id) {
              $(el).addClass('active')
            }
          });
        }
      },
      //勾选车位
      selectUnitst: function () {
        var _this = this;
        for (var s = 0; s < this.projectInfo.stdata.length; s++) {
          var wpAct = this.projectInfo.stdata[s].stop;
          $('.st-list span').each(function (index, el) {
            for (var st = 0; st < wpAct.length; st++) {
              if ($(el).attr('data-posId') == wpAct[st].stop_id) {
                $(el).addClass('active')
              }
            }
          });
        }
        for (var w = 0; w < this.projectInfo.wpdata.length; w++) {
          var wpAct = this.projectInfo.wpdata[w].stop;
          $('.wp-list span').each(function (index, el) {
            for (var wp = 0; wp < wpAct.length; wp++) {
              if ($(el).attr('data-posId') == wpAct[wp].stop_id) {
                $(el).addClass('active')
              }
            }
          });
        }
      },
      //单元添加
      queryAddunit: function () {
        this.projectInfo.unitFlag = true;
        this.bounced.unitFlag = false;
        this.projects.unitdata = [];
        this.projects.floorsdata = [];
        this.projects.stWpdata = [];
        this.projects.buildingId = null;
        this.projects.unitId = null;
        this.projectInfo.units = JSON.parse(JSON.stringify(this.unitData));
        this.getname = { buildname: null, unitname: null, floorname: null, stop_acreage: null, fname: null };
        $('.floor-select span, .unit-select span, .building-select span').text('请选择')
      },
      queryAddst: function () {
        this.bounced.stFlag = false;
        this.projectInfo.stFlag = true;
        this.projects.unitdata = [];
        this.projects.stWpdata = [];
        this.projects.floorsdata = [];
        this.projects.buildingId = null;
        this.projects.unitId = null;
        this.projectInfo.stdata = JSON.parse(JSON.stringify(this.stData));
        this.getname = { buildname: null, unitname: null, floorname: null, stop_acreage: null, fname: null };
        $('.floor-select span, .unit-select span, .building-select span').text('请选择')
      },
      queryAddwp: function () {
        this.bounced.wpFlag = false;
        this.projectInfo.wpFlag = true;
        this.projects.unitdata = [];
        this.projects.floorsdata = [];
        this.projects.stWpdata = [];
        this.projects.buildingId = null;
        this.projects.unitId = null;
        this.projectInfo.wpdata = JSON.parse(JSON.stringify(this.wpData));
        this.getname = { buildname: null, unitname: null, floorname: null, stop_acreage: null, fname: null };
        $('.floor-select span, .unit-select span, .building-select span').text('请选择')
      },
      querysAdd: function (n) {
        if (n == 1) {
          this.projectInfo.unitFlag = true;
          this.bounced.unitFlag = false;
          this.projects.unitdata = [];
          this.projects.floorsdata = [];
          this.projects.stWpdata = [];
          this.projects.buildingId = null;
          this.projects.unitId = null;
          this.getname = { buildname: null, unitname: null, floorname: null, stop_acreage: null, fname: null };
          $('.floor-select span, .unit-select span, .building-select span').text('请选择')
          this.unitData = JSON.parse(JSON.stringify(this.projectInfo.units));
        }
        if (n == 2) {
          this.bounced.wpFlag = false;
          this.projectInfo.wpFlag = true;
          this.projects.unitdata = [];
          this.projects.floorsdata = [];
          this.projects.stWpdata = [];
          this.projects.buildingId = null;
          this.projects.unitId = null;
          this.getname = { buildname: null, unitname: null, floorname: null, stop_acreage: null, fname: null };
          $('.floor-select span, .unit-select span, .building-select span').text('请选择')
          this.wpData = JSON.parse(JSON.stringify(this.projectInfo.wpdata));
        }
        if (n == 3) {
          this.bounced.stFlag = false;
          this.projectInfo.stFlag = true;
          this.projects.unitdata = [];
          this.projects.stWpdata = [];
          this.projects.floorsdata = [];
          this.projects.buildingId = null;
          this.projects.unitId = null;
          this.getname = { buildname: null, unitname: null, floorname: null, stop_acreage: null, fname: null };
          $('.floor-select span, .unit-select span, .building-select span').text('请选择')
          this.stData = JSON.parse(JSON.stringify(this.projectInfo.stdata));
        }
      },
      //删除单元
      delUnit: function (i) {
        this.unitData.splice(i, 1)
        this.projectInfo.units = JSON.parse(JSON.stringify(this.unitData));
      },
      //删除车位
      delst: function (i, n) {
        this.stData[i].stop.splice(n, 1)
        if (!this.stData[i].stop.length) {
          this.stData.splice(i, 1)
        }
        this.projectInfo.stdata = JSON.parse(JSON.stringify(this.stData));
      },
      //删除工位
      delwp: function (i, n) {
        this.wpData[i].stop.splice(n, 1)
        if (!this.wpData[i].stop.length) {
          this.wpData.splice(i, 1)
        }
        this.projectInfo.wpdata = JSON.parse(JSON.stringify(this.wpData));
      },
      //获取车位工位单元
      getStWp: function (id, name, fname) {
        var _this = this;
        this.projects.floorId = id;
        this.getname.floorname = name;
        this.getname.fname = fname;
        $('.unit-select span').text('请选择')
        this.projects.unitdata = [];
        this.projects.stWpdata = []
        hlhttp.get({
          url: 'floor/units',
          data: {
            project_id: _this.projects.id,  //项目ID
            floor_id: id,  //楼层ID
            building_id: _this.projects.buildingId
          },
          success: function (res) {
            _this.projects.unitdata = res;
          }
        })
      },
      //获取车位工位
      getswDt: function (id, name, index) {
        var _this = this;
        this.projects.unitId = id;
        this.getname.unitname = name;
        this.uIndex = index;
        $('.st-unit span').removeClass('active')
        hlhttp.get({
          url: 'units/positions',
          data: { unit_id: id },
          success: function (res) {
            _this.projects.stWpdata = res;
            setTimeout(function () {
              _this.selectUnitst()
            }, 200);
          }
        })
      },
      //验证
      zlfname: function () {
        if (!this.zlfData.zlf_name) {
          hl.toast('请填写公司名称')
        }
      },
      validateIDcode: function (code) {
        if (code === 'C') {
          if (!this.zlfData.idcode) hl.toast('请填写纳税人识别号')
          return false;
        }
        if (code === 'P') {
          if (!this.zlfData.idcode) hl.toast('请填写身份证号')
          return false;
        }
      },
      validateEmail: function () {
        var email = this.zlfData.email
        if (!email) return false;
        if (email) {
          if (!hlValidateUtil.validateEmail(email)) {
            hl.toast('邮箱格式不正确')
            this.zlfData.email = null;
            return false;
          }
        }
      },
      zlfperson: function (n) {
        if (n == 1) {
          if (!this.zlfData.zlf_lperson) {
            hl.toast('请填写法人名称')
          }
        }
        if (n == 2) {
          if (!this.zlfData.zlf_sperson) {
            hl.toast('请填写签订人名称')
          }
        }
      },
      zlfphone: function (n) {
        function checkTel(tel) {
          var test = /^[\d\+\-\(\)]{10,20}$/i;
          return test.test(tel)
        }
        if (n == 1) {
          if (this.zlfData.zlf_lphone.length < 20) {
            if (!checkTel(this.zlfData.zlf_lphone)) {
              this.zlfData.zlf_lphone = '';
              hl.toast('请填写正确的联系方式')
            }
          } else {
            this.zlfData.zlf_lphone = ''
            hl.toast('号码错误')
          }
        }
        if (n == 2) {
          if (!this.zlfData.zlf_sphone) {
            hl.toast('请填写联系方式')
            return
          }
          if (this.zlfData.zlf_sphone.length < 20) {
            if (!checkTel(this.zlfData.zlf_sphone)) {
              this.zlfData.zlf_sphone = '';
              hl.toast('请填写正确的联系方式')
            }
          } else {
            this.zlfData.zlf_sphone = ''
            hl.toast('号码错误')
          }
        }
      },
      // 下一步之前的重复验证
      validateIsGoNextStep: function () {
        if (!this.zlfData.zlf_name) {
          hl.toast('请填写客户名称')
          return false;
        }
        if (!this.industryTypes.active) {
          hl.toast('请选择所属行业')
          return false;
        }
        if (!this.zlfData.idcode) {
          if (this.zlfType.active === 'C') {
            hl.toast('请填写纳税人识别号')
            return false;
          }
          if (this.zlfType.active === 'P') {
            hl.toast('请填写身份证号')
            return false;
          }
        }
        if (!this.zlfData.zlf_sperson) {
          hl.toast('请填写联系人')
          return false;
        }
        if (!this.zlfData.zlf_sphone) {
          hl.toast('请填写联系电话')
          return false;
        }
        if (!this.channelType.selected.code) {
          hl.toast('请填写渠道分类')
          return false;
        }
        // if (!this.zlfData.zlf_address) {
        //   hl.toast('请填写通讯地址')
        //   return false;
        // }
        return true;
      },
      // 检测自定义字段填写是否符合要求
      checkCustom() {
        let flag = true
				console.log(this.resData)
				this.resData.map(item => {
					if (item.requiredFlag == 'Y' && (!item.value || !item.value.length) && item.type != 'line') {
					  flag = false
					}
				})
        return flag
      },
      //下一步
      nextData: function () {
        if (!this.validateIsGoNextStep()) return;
        if(!this.checkCustom()){
          hl.toast('请完成自定义字段')
          return
        }
        window.sessionStorage.setItem('contract_upload_file', JSON.stringify(this.fileList))
        var nums = 0;
        this.unitData.map(function (item) {
          nums += Number(item.unit_acreage)
        })
        this.projectInfo.units = JSON.parse(JSON.stringify(this.unitData));

        if (window.sessionStorage.getItem('CREATED_CONTRACT_SECOND_STEP')) {
          var d = JSON.parse(window.sessionStorage.getItem('CREATED_CONTRACT_FIRST_STEP'));
          var p = JSON.parse(window.sessionStorage.getItem('CREATED_CONTRACT_SECOND_STEP'));

          if (this.contactType.active != d.contactType.active) {
            if (window.sessionStorage.getItem('CREATED_CONTRACT_SECOND_STEP')) {
              p.rentBill.oPrice = '';
              p.rentBill.dRent = '';
              p.rentBill.mRent = '';
              p.rentBill.pay = '';
              p.rentBill.rentPercent = '';
              p.rentBill.bet = '';
              p.rentBill.menoy = '';
              p.rentBill.proportion = '';
              p.oPrice = '';
              p.dRent = '';
              p.mRent = '';
              p.menoy = '';
              p.rentLadder = []
              p.copyRentLadderArr = []
              window.sessionStorage.setItem('CREATED_CONTRACT_SECOND_STEP', JSON.stringify(p))
            }
          }

          if (this.wpNum != p.wpNums) {
            p.rentBill.oPrice = '';
            p.rentBill.dRent = '';
            p.rentBill.mRent = '';
            p.rentBill.pay = '';
            p.rentBill.rentPercent = '';
            p.rentBill.bet = '';
            p.rentBill.menoy = '';
            p.rentBill.proportion = '';
            p.oPrice = '';
            p.dRent = '';
            p.mRent = '';
            p.menoy = '';
            p.rentLadder = [];
            p.copyRentLadderArr = []
            window.sessionStorage.setItem('CREATED_CONTRACT_SECOND_STEP', JSON.stringify(p))
          }

          if (nums != p.atAges) {
            p.rentBill.oPrice = '';
            p.rentBill.dRent = '';
            p.rentBill.mRent = '';
            p.rentBill.pay = '';
            p.rentBill.rentPercent = '';
            p.rentBill.bet = '';
            p.rentBill.menoy = '';
            p.rentBill.proportion = '';
            p.oPrice = '';
            p.dRent = '';
            p.mRent = '';
            p.menoy = '';
            p.rentLadder = [];
            p.copyRentLadderArr = []
            window.sessionStorage.setItem('CREATED_CONTRACT_SECOND_STEP', JSON.stringify(p))
          }
        }

        if (!this.unitData.length && !this.wpData.length && !this.stData.length) {
          hl.toast('请选择项目')
          return
        }

        console.log(this.$data);

				if (this.resData.length) {
					function replaceData(type, val) {
						if (type == 'file') {
							let files = []
							if (val) {
								val.map(item => {
									files.push(item.response ? item.response : item)
								})
							}
							return JSON.stringify(files)
						} else {
							return ['select', 'radio', 'checkbox'].indexOf(type) > -1 ? JSON.stringify(val) : val
						}
					}

					this.resData.map(item => {
						this.tmpData.push({
							componentCode: item.code,
							componentType: item.type,
							property: replaceData(item.type, item.value)
						})
					})
				}

        window.sessionStorage.setItem('CREATED_CONTRACT_FIRST_STEP', JSON.stringify(this.$data))

        var self = this;
        hlhttp.put({
          url: 'check_my_customer',
          data: { customer_name: self.zlfData.zlf_name },
          success: function (res) {
            if (res.myself == 'Y') {
              if (self.contractId && hlUrlUtil.GetQueryString('relet') == 'true') {
                hlUrlUtil.goTo('contractNew2', { id: self.contractId, ddtab: true, relet: true })
                return
              }
              if (self.contractId) {
                hlUrlUtil.goTo('contractNew2', { id: self.contractId, ddtab: true })
                return
              }
              hlUrlUtil.goTo('contractNew2', { ddtab: true })
            }

            if (res.myself == 'N') {
              hl.toast('客户已存在')
            }
          }
        })
      },
      //取消
      cancellist: function () {
        hlUrlUtil.goTo('contract', { ddtab: true })
        var storageKey = [
          'CREATED_CONTRACT_FIRST_STEP',
          'CREATED_CONTRACT_SECOND_STEP'
        ]
        hlStorage.ssClearMultipleKey(storageKey)
      },
      getProjectName: function (proId) {
        var self = this;
        hlhttp.get({
          url: 'user/projects',
          success: function (data) {
            if (!data.length) return;
            self.projects.list = data.delArrCf();
            data.map(function (_item) {
              if (proId && _item.projectId == proId) {
                self.projectInfo.project_name = _item.projectName
                self.zlfData.c_code = _item.contractNoPrefix
                self.zlfData.name = _item.contractNamePrefix
              }
            })
          }
        })
      },
      ///获取意向信息
      getIntent(id) {
        hlhttp.get({
          url: 'contract/intent',
          data: { id: id },
          success: (data) => {
            this.zlfType.active = data.zlfInfo.zlfType == 'PE' ? 'P' : 'C';
            this.zlfData.zlf_name = data.zlfInfo.zlfName;
            this.zlfData.zlf_id = data.zlfInfo.zlfId;
            this.industryTypes.name = data.zlfInfo.zlfIndustryVal;
            this.industryTypes.active = data.zlfInfo.zlfIndustryType;
            this.zlfData.idcode = data.zlfInfo.idcode;
            this.zlfData.email = data.zlfInfo.email;
            // 合同：lperson是法人，sperson是联系人
            // 意向：lperson是联系人，sperson是法人
            // 意向转合同，需要对换联系人、法人信息
            this.zlfData.zlf_lperson = data.zlfInfo.zlfSperson;
            this.zlfData.zlf_lphone = data.zlfInfo.zlfSphone;
            this.zlfData.zlf_sperson = data.zlfInfo.zlfLperson;
            this.zlfData.zlf_sphone = data.zlfInfo.zlfLphone;

            this.channelType.selected.name = data.zlfInfo.channelCategoryVal;
            this.channelName.selected.name = data.zlfInfo.channelNameVal;
            this.channelType.selected.code = data.zlfInfo.channelCategoryCode;
            this.channelName.selected.code = data.zlfInfo.channelNameCode;
            this.zlfData.zlf_address = data.zlfInfo.zlfAddress;
            this.projectInfo.project_id = data.projectInfo.projectId;
            this.projects.id = data.projectInfo.projectId;
            this.contactType.active = data.intentType;
            this.intent.intentDeductibleAmount = data.intentDeductibleAmount;
            if(data.zlfInfo.channelNameCode){
              this.selectChannelName({
                code:data.zlfInfo.channelNameCode,
                name:data.zlfInfo.channelNameVal
              })
            }
            //单元
            if (data.intentType == 'ER') {
              this.projectInfo.unitFlag = true;
              data.projectInfo.units.map(item => {
                this.unitData.push({
                  "building_id": item.buildingId,
                  "building_name": item.buildingName,
                  "floor_id": item.floorId,
                  "floor_num": item.floorNum,
                  "floor_name": item.floorNum,
                  "unit_name": item.unitName,
                  "unit_acreage": item.unitAcreage,
                  "unit_id": item.unitId,
									business_type: item.businessType
                })
              })
            }
            //工位
            if (data.intentType == 'WR') {
              let wpArr = hlArrayUtil.removeRepeat(data.projectInfo.wps, 'unitId')
              let newWp = []
              wpArr.map(item => {
                newWp.push({
                  "building_id": item.buildingId,
                  "building_name": item.buildingName,
                  "floor_id": item.floorId,
                  "floor_num": item.floorNum,
                  "floor_name": item.floorNum,
                  "unit_name": item.unitName,
                  "unit_id": item.unitId,
                  "stop": []
                })
              })
              data.projectInfo.wps.map(item => {
                newWp.map(item1 => {
                  if (item.unitId == item1.unit_id) {
                    item1.stop.push({ stop_name: item.wpName, stop_id: item.wpId, business_type: item.businessType })
                  }
                })
              })
              this.wpData = newWp
              if (this.wpData.length) {
                this.projectInfo.wpFlag = true;
              }
              this.projectInfo.wpdata = JSON.parse(JSON.stringify(this.wpData));
            }
            //车位
            if (data.projectInfo.stops.length) {
              let stArr = hlArrayUtil.removeRepeat(data.projectInfo.stops, 'unitId')
              let newSt = []
              stArr.map(item => {
                newSt.push({
                  "building_id": item.buildingId,
                  "building_name": item.buildingName,
                  "floor_id": item.floorId,
                  "floor_num": item.floorNum,
                  "floor_name": item.floorNum,
                  "unit_name": item.unitName,
                  "unit_id": item.unitId,
                  "stop": []
                })
              })
              data.projectInfo.stops.map(item => {
                newSt.map(item1 => {
                  if (item.unitId == item1.unit_id) {
                    item1.stop.push({ stop_name: item.stopName, stop_id: item.stopId, business_type: item.businessType })
                  }
                })
              })
              this.stData = newSt
              if (this.stData.length) {
                this.projectInfo.stFlag = true;
              }
              this.projectInfo.stdata = JSON.parse(JSON.stringify(this.stData));
            }
            this.getProjectName(this.projectInfo.project_id)
          }
        })
      },
      //客户详情跳转过来的
      customerInfo() {
        let data = JSON.parse(unescape(hlUrlUtil.GetQueryString('params')))
				console.log(data.zlf_id)
        this.zlfType.active = data.code == 'PE' ? 'P' : 'C';
        this.zlfData.zlf_name = data.name;
        this.zlfData.zlf_id = data.zlf_id;
        this.industryTypes.name = data.industryName;
        this.industryTypes.active = data.industryType;
        this.zlfData.idcode = data.icode;
        this.zlfData.email = data.email;
        this.zlfData.zlf_lperson = data.lperson;
        this.zlfData.zlf_lphone = data.phone;
        this.zlfData.zlf_sperson = data.lperson;
        this.zlfData.zlf_sphone = data.phone;
        this.channelType.selected.name = data.channelCategoryVal;
        this.channelName.selected.name = data.channelNameVal;
        this.channelType.selected.code = data.channelCategoryCode;
        this.channelName.selected.code = data.channelNameCode;
        this.zlfData.zlf_address = data.address;
      },
      //租控工位车位
      rentUnitInfo() {

        console.log(decodeURIComponent(decodeURIComponent( hlUrlUtil.GetQueryString('RENT_WPST_UNIT_MES'))))


        let data = JSON.parse(decodeURIComponent(decodeURIComponent( hlUrlUtil.GetQueryString('RENT_WPST_UNIT_MES'))))

        // let posotion = JSON.parse(unescape(hlUrlUtil.GetQueryString('posotion')))

        this.projectInfo.project_id = data.projectId;
        this.projects.id = data.projectId;
        this.getProjectName(this.projects.id)

        function positionArr() {
          let tempArr = [], newArr = [];
          data.stop.map(item => {
            tempArr.push({ stop_id: item.stop_id, stop_name: item.stop_name })
          })
          newArr = [
            {
              building_id: data.buildingId,
              building_name: data.buildingName,
              floor_id: data.floorId,
              floor_name: data.floorName,
              floor_num: data.floorNum,
              stop: tempArr,
              unit_acreage: data.unitAcreage,
              unit_id: data.unitId,
              unit_name: data.unitName
            }
          ]
          return newArr
        }

        if (data.unitType == 'WP') {
          this.contactType.active = 'WR'
          this.projectInfo.wpFlag = true
          this.wpData = positionArr()
          this.projectInfo.wpdata = positionArr()
        }

        if (data.unitType == 'ST') {
          this.projectInfo.stFlag = true
          this.stData = positionArr()
          this.projectInfo.stdata = positionArr()
        }
      },
    },
    beforeMount: function () {
      if (window.sessionStorage.getItem('contract_upload_file')) {
        this.fileList = JSON.parse(window.sessionStorage.getItem('contract_upload_file'))
      }
      if (hlUrlUtil.GetQueryString('clear')) {
        window.sessionStorage.clear()
      }
      var self = this;

      // =========  展示由意向转为合同跳转过来的信息  =============
      if (hlUrlUtil.GetQueryString('intentId')) {
        this.intent.id = hlUrlUtil.GetQueryString('intentId')
        this.getIntent(this.intent.id)
        return false;
      }

      // =========  展示合同上一步缓存的信息  =============
      if (window.sessionStorage.getItem('CREATED_CONTRACT_FIRST_STEP')) {
        var data = JSON.parse(window.sessionStorage.getItem('CREATED_CONTRACT_FIRST_STEP'));
        this.zlfData = data.zlfData
        this.bounced = data.bounced;
        this.contactType = data.contactType;
        this.industryTypes = data.industryTypes;
        this.channelType = data.channelType;
        this.channelName = data.channelName;
        this.allChannelNameList = data.allChannelNameList;
        this.projectInfo = data.projectInfo;
        this.projects = data.projects;
        this.zlfType = data.zlfType;
        this.wpData = data.wpData;
        this.unitData = data.unitData;
        this.stData = data.stData;
        this.intent = data.intent;
        this.mediationData = data.mediationData
        self.getProjectName()
        return false;
      }




      console.log(decodeURIComponent(decodeURIComponent( hlUrlUtil.GetQueryString('RENT_ST_POSITION_MES'))))
      // =========  展示由租控跳转过来的信息  =============
      // 工位单元
      if (hlUrlUtil.GetQueryString('RENT_WP_POSITION_MES')) {
        var d = JSON.parse(decodeURIComponent(decodeURIComponent( hlUrlUtil.GetQueryString('RENT_WP_POSITION_MES'))));
        this.projectInfo.project_id = d.projectId;
        this.projects.id = d.projectId;
        self.getProjectName(this.projects.id)

        this.contactType.active = d.contractType;
        this.wpData.push(d.units)
        if (this.wpData.length) {
          this.projectInfo.wpFlag = true;
        }
        this.projectInfo.wpdata = JSON.parse(JSON.stringify(this.wpData));
        return false;
      }
      // 车位单元
      if (hlUrlUtil.GetQueryString('RENT_ST_POSITION_MES')) {
        var d = JSON.parse(decodeURIComponent(decodeURIComponent( hlUrlUtil.GetQueryString('RENT_ST_POSITION_MES'))));
        this.projectInfo.project_id = d.projectId;
        this.projects.id = d.projectId;
        self.getProjectName(this.projects.id)

        if (!d.units.stop) {
          this.unitData.push(d.units)
          if (this.unitData.length) {
            this.projectInfo.unitFlag = true;
          }
          this.projectInfo.units = JSON.parse(JSON.stringify(this.unitData));
        }
        if (d.units.stop) {
          this.stData.push(d.units)
          if (this.stData.length) {
            this.projectInfo.stFlag = true;
          }
          this.projectInfo.stdata = JSON.parse(JSON.stringify(this.stData));
        }

        return false;
      }
      // 普通单元
      if (hlUrlUtil.GetQueryString('RENT_BU_UNIT_MES')) {
        var d = JSON.parse(decodeURIComponent(decodeURIComponent( hlUrlUtil.GetQueryString('RENT_BU_UNIT_MES'))));
        this.projectInfo.project_id = d.projectId;
        this.projects.id = d.projectId;
        this.projectInfo.unitFlag = true;
        this.unitData.push(d.units)
        self.getProjectName(this.projectInfo.project_id)
        return false;
      }
      self.getProjectName()
    },
    mounted: function () {

			if (window.sessionStorage.getItem('CREATED_CONTRACT_FIRST_STEP')) {
			  var data = JSON.parse(window.sessionStorage.getItem('CREATED_CONTRACT_FIRST_STEP'));
				if (data.resData.length) {
					function replaceData(type, val) {
						if (type == 'file') {
							let files = []
							val.map(item => {
								files.push(item.response ? item.response : item)
							})
							return JSON.stringify(files)
						} else {
							return ['select', 'radio', 'checkbox'].indexOf(type) > -1 ? JSON.stringify(val) : val
						}
					}

					data.resData.map(item => {
						this.tmpData.push({
							componentCode: item.code,
							componentType: item.type,
							property: replaceData(item.type, item.value)
						})
					})

				}

			}


      fileUpload('.upload-file-button', uploadUrl, function (res) {
        _this.progress = ''
        _this.fileList.push(res.json)
        window.sessionStorage.setItem('contract_upload_file', JSON.stringify(_this.fileList))

      }, function (val) {
        _this.progress = parseInt((val.loaded / val.total) * 100) + '%'
      })
      if (hlUrlUtil.GetQueryString('params')) {
        this.customerInfo()
      }
      if (localStorage.getItem('contractNew1Data')) {
        let data0 = JSON.parse(localStorage.getItem('contractNew1Data'))

        hlUrlUtil.addURLParam({ 'unit': escape(JSON.stringify(data0.unit)), 'posotion': escape(JSON.stringify(data0.posotion)) })
        sessionStorage.setItem('contractNew1Data', localStorage.getItem('contractNew1Data'))
        setTimeout(() => {
          this.rentUnitInfo()
        }, 200)
        localStorage.removeItem('contractNew1Data')
      }

      if (hlUrlUtil.GetQueryString('RENT_WPST_UNIT_MES')) {
        this.rentUnitInfo()
      }

      this.getindustryTypes()
      this.getChannelType()
      this.getChannelName()
      this.getContractCode()
      hlSelectUi()

      var _this = this;
      $(document).click(function (event) {
        _this.customersFlag = false;
      });

    }
  })


  function isNull(str) {
    if (str == "") return true;
    var regu = "^[ ]+$";
    var re = new RegExp(regu);
    return re.test(str);
  }


}())
